<template>
  <view>
    正在请求微信中...
  </view>
</template>

<script>
import base64 from '../../util/base64'
import Pay from '../../api/pay'
const payModel = new Pay()
export default {
  data() {
    return {
      // redirect: ''
    }
  },
  onLoad(options) {
    // const { code, state, redirect } = this.$route.query
    const { code, state, redirect } = options
    // console.log(options, base64.parse(redirect))
    payModel.get({
      code,
      user_id: state
    }).then(() => {
      // 后退地址(比如从支付过来)
      // this.$router.push(this.redirect)
      const url = base64.parse(redirect)
      console.log(url)
      if (url.indexOf('/center/index') > -1) {
        uni.switchTab({
          url
        })
      } else {
        uni.navigateTo({
          url
        })
      }

    })
  }
}
</script>

<style scoped lang="scss">

</style>
